Check the text handle role, instead of looking for the other handle
visibility. The other handle may be invisible during selection mode
(e.g. pointing to offscreen contents). This fixes both this code
switching to cursor mode out of the blue, and possible crashes later
on as this handle might be hidden in the process, while its own event
controller is handling events on the parent surface.
*old_iter = iter;
if (handle == priv->text_handles[TEXT_HANDLE_CURSOR] &&
- !gtk_widget_is_visible (GTK_WIDGET (priv->text_handles[TEXT_HANDLE_SELECTION_BOUND])))
+ gtk_text_handle_get_role (priv->text_handles[TEXT_HANDLE_CURSOR]) == GTK_TEXT_HANDLE_ROLE_CURSOR)
gtk_text_buffer_place_cursor (buffer, &cursor);
else
gtk_text_buffer_select_range (buffer, &cursor, &bound);